home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / keyb / click10.zip / CLICK.ASM next >
Assembly Source File  |  1991-04-10  |  4KB  |  140 lines

  1. ;; CLICK.ASM  v1.0
  2. ;;
  3. ;; This is a small TSR program that produces a click each time
  4. ;; a key is pressed (and optionally when it is released).
  5. ;; Repeating keys cause repeating clicks.
  6. ;; The program hooks interrupt 9h (keyboard).
  7. ;;
  8. ;; Adjust volume by changing duration of click (above label `delay')
  9. ;;
  10. ;; Written in February 1990 by Erik Tamboer, Amsterdam, The Netherlands
  11. ;; email: tamboer@cs.vu.nl  (probably until July 1991)
  12. ;;
  13. ;; Usage: just type CLICK at the DOS prompt or include a line
  14. ;; with only the word CLICK in your \AUTOEXEC.BAT file. There are
  15. ;; no command line switches.
  16. ;;
  17. ;; This program is free. You may use it for anything you like.
  18. ;; I have had no problems whatsoever with this program, but I
  19. ;; cannot guarantee that it will work in every environment.
  20. ;;
  21. ;; This code covers about everything I know about assembler programming
  22. ;; (I am a C programmer, really) so I am not claiming perfection ;-)
  23.  
  24.  
  25. cseg    segment byte
  26.         assume  cs:cseg,ds:cseg,es:cseg,ss:cseg
  27.         org     100h
  28.  
  29. start:  jmp     install
  30.  
  31. old_int9_vector label   dword
  32. old_int9_off    dw      ?
  33. old_int9_seg    dw      ?
  34.  
  35.  
  36. new_int9:
  37.         push    ax
  38.         in      al,60h                  ; get key scan code
  39.  
  40.         ; Delete the next two lines if you want keys to click also
  41.         ; when they are released.
  42.  
  43. ;     test     al,80h
  44. ;     jnz     noclick
  45.  
  46.         ; You can disable the clicking of keys such as NumLock and Shift.
  47.         ; For each of these special keys that you DO want to click,
  48.         ; delete the corresponding test and jump.
  49.         ; Note that some of these keys may actually repeat!
  50.  
  51.         cmp     al,1dh                  ; Ctrl
  52.         jz      noclick
  53.         cmp     al,2ah                  ; Left Shift
  54.         jz      noclick
  55.         cmp     al,36h                  ; Right Shift
  56.         jz      noclick
  57.         cmp     al,38h                  ; Alt
  58.         jz      noclick
  59.         cmp     al,3ah                  ; Caps Lock
  60.         jz      noclick
  61.         cmp     al,45h                  ; Num Lock
  62.         jz      noclick
  63.         cmp     al,46h                  ; Scroll Lock
  64.         jz      noclick
  65.         pop     ax
  66.  
  67. click:
  68.         push    ax
  69.         push    cx
  70.         mov     al,0b6h
  71.         out     43h,al
  72.         mov     cx,180h                 ; frequency
  73.         mov     al,cl
  74.         out     42h,al
  75.         mov     al,ch
  76.         out     42h,al
  77.         in      al,61h
  78.         or      al,3
  79.         out     61h,al
  80.         mov     cx,28h                  ; duration (controls volume)
  81. delay:  loop    delay
  82.         in      al,61h
  83.         and     al,0fch
  84.         out     61h,al
  85.         pop     cx
  86.  
  87. noclick:
  88.         pop     ax
  89.         pushf
  90.         call    cs:old_int9_vector      ; call original int 9 handler
  91.         iret
  92.  
  93. keep    label   byte
  94.  
  95. msg1    db      'Keyboard CLICK ',04h,' Written by Erik Tamboer, 1990'
  96.         db      0dh,0ah,'$'
  97. msg2    db      'CLICK installed',0dh,0ah,'$'
  98. msg3    db      'CLICK already installed',0dh,0ah,'$'
  99.  
  100. install:
  101.         mov     es,ds:2ch               ; free our environment,
  102.         mov     ah,49h                  ;  this makes us
  103.         int     21h                     ;   even smaller
  104.         mov     dx,offset msg1          ; identify ourselves
  105.         mov     ah,9
  106.         int     21h
  107.         mov     ah,35h
  108.         mov     al,9
  109.         int     21h                     ; get keyboard interrupt vector
  110.         cmp     bx,offset new_int9      ; are we installed yet? (unreliable!)
  111.         jne     install1                ; if not, install
  112.         mov     dx,offset msg3          ; else say so and exit
  113.         mov     ah,9
  114.         int     21h
  115.         int     20h                     ; exit
  116.         
  117. install1:
  118.         mov     old_int9_off,bx         ; save old keyboard interrupt vector
  119.         mov     old_int9_seg,es
  120.  
  121. ; set keyboard interrupt to point to new_int9
  122.  
  123.         mov     ah,25h
  124.         mov     al,9
  125.         mov     dx,offset new_int9
  126.         int     21h
  127.  
  128.  
  129.         mov     dx,offset msg2          ; say we're installed
  130.         mov     ah,9
  131.         int     21h
  132.  
  133. ; terminate and stay partially resident
  134.  
  135.         mov     dx,offset keep+1
  136.         int     27h
  137.  
  138.         cseg    ends
  139.         end     start
  140.